package bai4;

import java.util.ArrayList;
import java.util.Scanner;

public class Sinhvien {
	private int stt;
	private int maSV;
	private int maLop;
	private String tenSV;
	private double diem[];
	private String xepLoai;
	public Sinhvien(){

	}
	
	public Sinhvien(int stt, int maSV, int maLop, String tenSV, double[] diem,String xepLoai) {
		super();
		this.stt = stt;
		this.maSV = maSV;
		this.maLop = maLop;
		this.tenSV = tenSV;
		this.diem = diem;
		this.xepLoai=xepLoai;
	}
	

	public int getStt() {
		return stt;
	}

	public void setStt(int stt) {
		this.stt = stt;
	}

	public int getMaSV() {
		return maSV;
	}

	public void setMaSV(int maSV) {
		this.maSV = maSV;
	}

	public int getMaLop() {
		return maLop;
	}

	public void setMaLop(int maLop) {
		this.maLop = maLop;
	}

	public String getTenSV() {
		return tenSV;
	}

	public void setTenSV(String tenSV) {
		this.tenSV = tenSV;
	}

	public double[] getDiem() {
		return diem;
	}

	public void setDiem(double[] diem) {
		this.diem = diem;
	}
	

	public String getXepLoai() {
		return xepLoai;
	}

	public void setXepLoai(String xepLoai) {
		this.xepLoai = xepLoai;
	}

	public Sinhvien inputSinhvien(){
		Scanner ip=new Scanner(System.in);
//		System.out.println("Nhap so sinh vien can them: ");
//		int n=Integer.parseInt(ip.nextLine());
//		for(int j=1;j<=n;j++){
//			System.out.println("Nhap thong tin sinh vien thu "+j);
			System.out.println("Nhap Stt: ");
			stt=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap maSV: ");
			maSV=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap maLop: ");
			maLop=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap ten sinh vien: ");
			tenSV=ip.nextLine();
			diem=new double[3];
			System.out.println("Nhap diem sinh vien: ");
			for(int i=0;i<3;i++){
				System.out.print("diem"+"["+i+"]"+"=");
				diem[i]=Double.parseDouble(ip.nextLine());
//				String xepLoai="";
				double dtb=0;
				double tong = 0;
				tong+=diem[i];
				dtb=tong/3;
				if(dtb>=7.5){
					xepLoai="Gioi";
				}
				else if(dtb>=6.5&&dtb<7.5){
					xepLoai="Kha";
				}
				else xepLoai="Trung binh";
				
			}
		Sinhvien list=new Sinhvien(stt,maSV,maLop, tenSV,diem,xepLoai);
		return list;
	}
	public void add(Sinhvien sv)
	{int i=0;
	int length=0;
	String choice,choice2;
	Scanner ip=new Scanner(System.in);
	while(true)
	{
		try
		{
			System.out.printf("Nhap Thong Tin SV thu %d:\n",i+1);
			System.out.println("Nhap Stt: ");
			stt=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap ma: ");
			maSV=Integer.parseInt(ip.nextLine());
			System.out.println("Nhap ten sinh vien: ");
			tenSV=ip.nextLine();
			diem=new double[3];
			System.out.println("Nhap diem sinh vien: ");
			for(int j=0;j<3;j++){
				System.out.print("diem"+"["+j+"]"+"=");
				diem[j]=Double.parseDouble(ip.nextLine());}}
			catch(Exception e)
			{
				System.out.println("NHAP LOI......");
			}
			i++;
			length=i;
		}
	}
	public void display(Sinhvien sv){
		ArrayList<Sinhvien> arrsv=new ArrayList<Sinhvien>();
		arrsv.add(sv);

		for(int i=0;i<arrsv.size();i++){
			System.out.println(arrsv.get(i).getMaSV());
			System.out.println(arrsv.get(i).getTenSV());
		}
	}
	public String xepLoai(Sinhvien sv){
		String xepLoai="";
		double dtb=0;
		double tong = 0;
		for(int i=0;i<diem.length;i++){
			tong+=diem[i];
		}
		dtb=tong/3;
		if(dtb>=7.5){
			xepLoai="Gioi";
		}
		else if(dtb>=6.5&&dtb<7.5){
			xepLoai="Kha";
		}
		else xepLoai="Trung binh";
		return xepLoai;	
	}
	}
